﻿using mvcForum.Core.Interfaces.Data;
using System;
using System.Linq.Expressions;

namespace mvcForum.Core.Specifications {

	public static class AttachmentSpecifications {

		/// <summary>
		/// Specification for getting all attachments owned by a particular user.
		/// </summary>
		public class ByAuthor : ISpecification<Attachment> {
			private readonly ForumUser user;

			public ByAuthor(ForumUser user) {
				this.user = user;
			}

			public Expression<Func<Attachment, Boolean>> IsSatisfied {
				get {
					return a => a.AuthorId == this.user.Id;
				}
			}
		}
	}
}